package com.ruoyi.energy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.energy.domain.MjGuardAlarm;
import com.ruoyi.energy.service.IMjGuardAlarmService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 门禁入侵警告Controller
 *
 * @author cjie
 * @date 2021-07-29
 */
@Api(tags = " 门禁入侵警告")
@RestController
@RequestMapping("/mjGuardAlarm")
public class MjGuardAlarmController extends BaseController {
    @Autowired
    private IMjGuardAlarmService mjGuardAlarmService;

    /**
     * 查询门禁入侵警告列表
     */
    @ApiOperation(value="查询门禁入侵警告列表", notes="查询门禁入侵警告列表")
    @PreAuthorize(hasPermi = "energy:mjGuardAlarm:list")
    @GetMapping("/list")
    public TableDataInfo list(MjGuardAlarm mjGuardAlarm) {
        startPage();
        List<MjGuardAlarm> list = mjGuardAlarmService.selectMjGuardAlarmList(mjGuardAlarm);
        return getDataTable(list);
    }

    /**
     * 导出门禁入侵警告列表
     */
    @ApiOperation(value="导出门禁入侵警告列表", notes="导出门禁入侵警告列表")
    @PreAuthorize(hasPermi = "energy:mjGuardAlarm:export")
    @Log(title = "门禁入侵警告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MjGuardAlarm mjGuardAlarm) throws IOException {
        List<MjGuardAlarm> list = mjGuardAlarmService.selectMjGuardAlarmList(mjGuardAlarm);
        ExcelUtil<MjGuardAlarm> util = new ExcelUtil<MjGuardAlarm>(MjGuardAlarm.class);
        util.exportExcel(response, list, "门禁入侵警告数据");
    }
    /**
     * 获取门禁入侵警告详细信息
     */
    @ApiOperation(value="获取门禁入侵警告详细信息", notes="获取门禁入侵警告详细信息")
    @PreAuthorize(hasPermi = "energy:mjGuardAlarm:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(mjGuardAlarmService.selectMjGuardAlarmById(id));
    }

    /**
     * 新增门禁入侵警告
     */
    @ApiOperation(value="新增门禁入侵警告", notes="新增门禁入侵警告")
    @PreAuthorize(hasPermi = "energy:mjGuardAlarm:add")
    @Log(title = "门禁入侵警告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MjGuardAlarm mjGuardAlarm) {
        return toAjax(mjGuardAlarmService.insertMjGuardAlarm(mjGuardAlarm));
    }

    /**
     * 修改门禁入侵警告
     */
    @ApiOperation(value="修改门禁入侵警告", notes="修改门禁入侵警告")
    @PreAuthorize(hasPermi = "energy:mjGuardAlarm:edit")
    @Log(title = "门禁入侵警告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MjGuardAlarm mjGuardAlarm) {
        return toAjax(mjGuardAlarmService.updateMjGuardAlarm(mjGuardAlarm));
    }

    /**
     * 删除门禁入侵警告
     */
    @ApiOperation(value="删除门禁入侵警告", notes="删除门禁入侵警告")
    @ApiImplicitParam(name = "ids", value = "门禁入侵警告ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:mjGuardAlarm:remove")
    @Log(title = "门禁入侵警告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(mjGuardAlarmService.deleteMjGuardAlarmByIds(ids));
    }
}
